﻿using NP.BPMReportPlatform.Contract.Dtos;
using NP.BPMReportPlatform.Entities.BPM_Business.Contract;
using NP.BPMReportPlatform.Entities.BPM_Platform;
using NP.BPMReportPlatform.RecurringJobs.Dto;
using NP.BPMReportPlatform.UserTrial.Dto;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using static NP.BPMReportPlatform.Contract.Dtos.ContractEnum;

namespace NP.BPMReportPlatform.Contract
{
    public interface IContractService : IApplicationService
    {

        /// <summary>
        /// 根据条件合同订立
        /// </summary>
        /// <param name="searchQuery"></param>
        /// <returns></returns>
        Task<PagedResultDto<ContractUserListDto>> GetContractUserFormationList(SearchQueryDto searchQuery);

        /// <summary>
        /// 根据条件获取实习生协议人员清单
        /// </summary>
        /// <param name="searchQuery"></param>
        /// <returns></returns>
        Task<PagedResultDto<ContractUserListDto>> GetIntelContractUserFormationList(SearchQueryDto searchQuery);

        /// <summary>
        /// 根据条件获取退休返聘人员清单
        /// </summary>
        /// <param name="searchQuery"></param>
        /// <returns></returns>
        Task<PagedResultDto<ContractUserListDto>> GetRetirementContractUserFormationList(SearchQueryDto searchQuery);

        /// <summary>
        /// 根据人员主键ID初始化订立合同基本信息
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="isDetail">是否是查看明细</param>
        /// <returns></returns>
        UserContractEntity PackageUserContractInfo(string userId, bool isDetail = false);

        /// <summary>
        /// 根据数据获取当前合同编码
        /// </summary>
        /// <param name="contractType">合同类型</param>
        /// <param name="contractStartDate">合同开始时间</param>
        /// <param name="workNumber">员工编码</param>
        /// <param name="parentContractCode">父级合同：上一份合同</param>
        /// <returns></returns>
        string GenerateContractCode(string contractType, string contractStartDate, string workNumber, string parentContractCode);

        /// <summary>
        /// 保存合同订立
        /// </summary>
        /// <param name="entity">数据</param>
        /// <param name="type">1：立即生效 2：电子签</param>
        Task<string> SaveUserContract(UserContractEntity entity, int type);

        /// <summary>
        /// 根据条件
        /// </summary>
        /// <param name="searchQuery"></param>
        /// <returns></returns>
        Task<PagedResultDto<ContractUserListDto>> GetContractUserRenewalList(SearchQueryDto searchQuery);

        /// <summary>
        /// 根据人员工号获取续订合同信息
        /// </summary>
        /// <param name="workNumber"></param>
        /// <param name="parentContractCode">上一份合同</param>
        /// <returns></returns>
        ContractRenewalDto SearchUserContract(string workNumber, string parentContractCode);

        /// <summary>
        /// 下载合同
        /// </summary>
        /// <param name="processId"></param>
        /// <returns></returns>
        Task<string> DownloadContract(string processId);

        /// <summary>
        /// 流程任务 type:1 催办 2 作废
        /// </summary>
        /// <param name="type"></param>
        /// <param name="contractCode">合同编码</param>
        Task<string> ProcessTask(int type, string contractCode);

        /// <summary>
        /// 三方协议流程任务 type:1 催办 2 作废
        /// </summary>
        /// <param name="type"></param>
        Task<string> ProcessChangeTask(int type, string businessCode);

        /// <summary>
        /// 根据合同编码获取合同基本信息
        /// </summary>
        /// <param name="contractCode">合同编码</param>
        /// <returns></returns>
        UserContractEntity GetUserContractInfo(string contractCode);

        /// <summary>
        /// 根据类别导出对应的列表数据
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        Task<MemoryStream> ExportResultAsync(SearchQueryDto search);

        /// <summary>
        /// 合同三方协议变更
        /// </summary>
        /// <param name="searchQuery"></param>
        /// <returns></returns>
        Task<PagedResultDto<ContractUserListDto>> GetAllTripartiteContract(SearchQueryDto searchQuery);

        /// <summary>
        /// 根据条件查询--合同主体变更三方协议记录查询
        /// </summary>
        /// <param name="searchQuery"></param>
        /// <returns></returns>
        Task<PagedResultDto<ContractUserListDto>> GetTripartiteHistoryList(SearchQueryDto searchQuery);


        /// <summary>
        /// 生成变更合同协议编码
        /// </summary>
        /// <param name="workNumber">员工编码</param>
        /// <param name="contractCode">合同编码</param>
        /// <returns></returns>
        UserContractTripartiteAgreementEntity GenerateChangeContract(string workNumber, string contractCode);

        /// <summary>
        /// 保存变更合同
        /// </summary>
        /// <param name="entity">数据</param>
        /// <param name="type">1：立即生效 2：电子签</param>
        Task<string> SaveUserChangeContract(UserContractTripartiteAgreementEntity entity, int type);

        /// <summary>
        /// 根据查询条件查询-合同续签审批报表
        /// </summary>
        /// <param name="searchQuery">查询条件</param>
        /// <returns></returns>
        Task<PagedResultDto<UserContractRenewalProcessEntity>> GetContractRenewalProcessByFilter(SearchQueryDto searchQuery);

        /// <summary>
        /// 获取新员工
        /// </summary>
        /// <param name="workNumber"></param>
        /// <returns></returns>
        object GetNewStaff(string workNumber);

        /// <summary>
        /// 电子签推送失败重推
        /// </summary>
        /// <param name="contractId">合同ID</param>
        /// <returns></returns>
        Task<string> ReRequestESignSyncData(string contractId);

        /// <summary>
        /// 测试合同模板
        /// </summary>
        /// <returns></returns>
        Task<byte[]> TestContractTemplate(UserContractEntity entity);

        /// <summary>
        /// 导入主体变更协议
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task<ImportResultExt<TripartiteAgreementContractImportDto>> ImportTripartiteAgreementContracts(List<TripartiteAgreementContractImportDto> data);
    }
}
